package com.ala4.oxcafe.core.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * Entity基类
 *
 * @author ruoyi
 */
@Data
public class BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @TableField(value = "create_by", fill = FieldFill.INSERT)
    @Schema(description = "创建人")
    private String createBy;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新人")
    private String updateBy;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @TableField("remark")
    @Schema(description = "备注")
    private String remark;

    @TableLogic
    @Schema(title = "逻辑删除字段,是否删除0否1是")
    @TableField(value = "del_flag", fill = FieldFill.INSERT)
    private Integer delFlag;

    @Version
    @Schema(title = "版本号")
    @TableField(value = "version", fill = FieldFill.INSERT)
    private Long version;

    @TableField(exist = false)
    @Schema(description = "额外请求参数")
    private Map<String, Object> params;

    @TableField(exist = false)
    @Schema(description = "关键字搜索")
    private String searchValue;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }
}
